
<style type="text/css">
@import url(/keeper/~/keeper/css/login.css);
</style>

<div id="keeper-login-box">

  <div class="keeper-login-msg01">{{T . "Sign in Management Console"}}</div>

  <form id="keeper-login-form" action="#">

    <input type="hidden" name="continue" value="{{.continue}}">

    <div id="keeper-login-form-alert" class="alert hide ilf-group"></div>

    <div id="ilf-grp-input">
    <div class="ilf-group">
      <input type="text" class="ilf-input" name="uname" value="{{.uname}}" placeholder="{{T . "Username"}}">
    </div>

    <div class="ilf-group">
      <input type="password" class="ilf-input" name="passwd" placeholder="{{T . "Password"}}">
    </div>

    <div class="ilf-group">
      <button type="submit" class="ilf-btn">{{T . "Sign in"}}</button>
    </div>

    <!-- <div>
      <div class="ilf-help">
        <a href="#/keeper/user/forgot-pass">Forgot Password?</a>
      </div>
    </div> -->
    </div>
  </form>

  <div class="klb-footer">
    <img src="/keeper/~/keeper/img/keeper-s2-32.png"> 
    <a href="http://www.lesscompute.com" target="_blank">lessKeeper Distributed Lock Service</a>
  </div>

</div>

<script type="text/javascript">

//
var keeper_eh = $("#keeper-login-box").height();
$("#keeper-login-box").css({
    "top": "50%",
    "margin-top": - (keeper_eh / 2) + "px" 
});

setTimeout(function() {
    keeper_eh = $("#keeper-login-box").height();
    $("#keeper-login-box").css({
        "top": "50%",
        "margin-top": - (keeper_eh / 2) + "px" 
    });
    $("input[name=uname]").focus();
}, 100);

//
$("#keeper-login-form").submit(function(event) {

    event.preventDefault();

    $.ajax({
        type    : "POST",
        url     : "/keeper/user/login-auth",
        data    : $(this).serialize(),//JSON.stringify(req),
        timeout : 3000,
        //contentType: "application/json; charset=utf-8",
        success : function(rsp) {

            var rsj = JSON.parse(rsp);
            //console.log(rsp);

            if (rsj.status != 200) {
                lessAlert("#keeper-login-form-alert", 'alert-danger', rsj.message);
                return;
            }

            lessAlert("#keeper-login-form-alert", 'alert-success', "Successfully Sign-on. Page redirecting");
            $("#ilf-grp-input").hide(200);

            lessCookie.Set("access_token_keeper", rsj.data.access_token_keeper, 864000);

            window.setTimeout(function(){
                window.location = rsj.data.continue;
            }, 1500);
        },
        error: function(xhr, textStatus, error) {
            lessAlert("#keeper-login-form-alert", 'alert-danger', '{{T . "Internal Server Error"}}');
        }
    });
});

</script>

